//
//  LuckyRandomView.m
//  SMTools
//
//  Created by fengsh on 2018/12/30.
//  Copyright © 2018年 fengsh. All rights reserved.
//

#import "LuckyRandomView.h"
#import <Masonry/Masonry.h>

@implementation LuckyRandomView

- (instancetype)initWithFrame:(NSRect)frameRect
{
    self = [super initWithFrame:frameRect];
    if (self) {
        self.img_rand = [[NSImageView alloc]init];
        [self.img_rand setWantsLayer:YES];
        self.img_rand.layer.backgroundColor = [NSColor greenColor].CGColor;
        
        self.lb_random_name = [[NSTextField alloc]init];
        [self.lb_random_name setEditable:NO];
        [self.lb_random_name setSelectable:NO];
        [self.lb_random_name setBezeled:NO];
        [self.lb_random_name setBordered:NO];
        [self.lb_random_name setBackgroundColor:[NSColor clearColor]];
        [self.lb_random_name setFont:[NSFont boldSystemFontOfSize:30]];
        self.lb_random_name.textColor = [NSColor whiteColor];
        self.lb_random_name.alignment = NSTextAlignmentCenter;
        
        self.lb_random_phone = [[NSTextField alloc]init];
        self.lb_random_phone.textColor = [NSColor whiteColor];
        self.lb_random_phone.alignment = NSTextAlignmentCenter;
        [self.lb_random_phone setEditable:NO];
        [self.lb_random_phone setSelectable:NO];
        [self.lb_random_phone setBezeled:NO];
        [self.lb_random_phone setBordered:NO];
        [self.lb_random_phone setBackgroundColor:[NSColor clearColor]];
        [self.lb_random_phone setFont:[NSFont boldSystemFontOfSize:30]];
        
        [self addSubview:self.img_rand];
        [self addSubview:self.lb_random_name];
        [self addSubview:self.lb_random_phone];
        
        [self.img_rand mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(0));
            make.leading.equalTo(@(10));
            make.trailing.equalTo(@(-10));
            make.bottom.equalTo(self.lb_random_name.mas_top).offset(-10);
        }];
        
        [self.lb_random_phone mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(@(0));
            make.leading.trailing.equalTo(@(0));
            make.height.lessThanOrEqualTo(@(50));
        }];
        
        [self.lb_random_name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.lb_random_phone.mas_top).offset(-5);
            make.leading.trailing.equalTo(@(0));
            make.height.lessThanOrEqualTo(@(50));
        }];
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    
    // Drawing code here.
}

@end
